package jdbc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class jdbcdemo7
{
    public static void main(String[] args)
    {
        try(Connection con=DButil.getConnection();)
        {
            Statement sa=con.createStatement();
            String sql=" SELECT COUNT(*) count FROM CLASS C JOIN STUDENT S ON S.CLASS_ID=C.ID WHERE C.NAME='1年级1班'";
            ResultSet re=sa.executeQuery(sql);
            while(re.next())
            {
                String count=re.getString("count");
                System.out.println("一共"+count+"人");
            }
        } catch (SQLException e) {e.printStackTrace();}
    }
}
